<template>
  <dir>
    <h2>猜你喜欢的栏目</h2>
    <span v-for="item in arr" :key="item"
      ><input type="checkbox" @click="check(item)" />{{ item }}</span
    >
    <ul>
      <li v-for="item in arr1" :key="item">{{ item }}</li>
    </ul>
  </dir>
</template>

<script>
export default {
  data() {
    return {
      arr: ["科幻", "喜剧", "动漫", "冒险", "科技", "军事", "娱乐", "奇闻"],

      arr1: [],
    };
  },
  methods: {
    check(a) {
      const n = this.arr.findIndex((item) => item === a);
      console.log(n);
      this.arr1.push(this.arr[n]);
    },
  },
};
</script>

<style scoped></style>
